﻿Public Class KhachHangDAO
    Public Shared Function SelectAll() As DataTable
        Dim strSQL As String = "Select * From KhachHang"
        Dim dt As DataTable
        dt = SQLProvider.ExecQuery(strSQL)
        Return dt

    End Function

    Public Shared Sub Insert(ByVal _khachhang As KhachHangDTO)
        Dim strSQL As String = "Insert into KhachHang(TenKH,DiaChi,Email,DienThoai)" _
        & "  Values('" & _khachhang.TenKhachHang & "','" _
        & _khachhang.DiaChi & "',' " & _khachhang.Email & "','" _
        & _khachhang.DienThoai & "')"
        SQLProvider.ExecNoneQuery(strSQL)

    End Sub

    Public Shared Sub Delete(ByVal _khachhang As KhachHangDTO)
        Dim strSQL As String = "Delete from KhachHang where IDKH = " & _khachhang.MaKhachHang
        SQLProvider.ExecNoneQuery(strSQL)
    End Sub

    Public Shared Sub Update(ByVal _khachhang As KhachHangDTO)
        Dim strSQL As String = "Update KhachHang set TenKH = '" & _khachhang.TenKhachHang & "', DiaChi = '" & _khachhang.DiaChi & "', Email = '" & _khachhang.Email & "', DienThoai ='" & _khachhang.DienThoai & "'where IDKH = " & _khachhang.MaKhachHang
        SQLProvider.ExecNoneQuery(strSQL)
    End Sub
End Class
